package project.gui;

import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JPanel;
import javax.swing.table.DefaultTableModel;

import project.elements.base.WorkShop;
import project.elements.priority.PriorityByCriticalRatio;
import project.elements.priority.PriorityByEarliestDueDate;
import project.elements.priority.PriorityByLongestImminentOperationTime;
import project.elements.priority.PriorityByShortestImminentOperationTime;
import project.elements.priority.PriorityBySmallestDynamicSlack;
import project.elements.priority.PriorityBySmallestStaticSlack;
import project.elements.priority.PriorityCalculator;

/**
 * 
 * @author Zsolt
 */
public class AppWindow2 extends javax.swing.JFrame {

	private final WorkShop ws;

	/**
	 * Creates new form AppWindow
	 */
	public AppWindow2() {
		initComponents();
		this.ws = new WorkShop();
		// this.ws.setScheduler(new CriticalRatio());
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed"
	// desc="Generated Code">//GEN-BEGIN:initComponents
	private void initComponents() {

		jDialog_Add_Machine = new javax.swing.JDialog();
		jLabel_jdialog_add_machine_add_machine = new javax.swing.JLabel();
		jLabel_jdialog_add_machine_machine_name = new javax.swing.JLabel();
		jTextField_jdialog_machine_add_machine_name = new javax.swing.JTextField();
		jButton_jdialog_add_machine_add = new javax.swing.JButton();
		jDialog_Add_Job = new javax.swing.JDialog();
		jLabel_jdialog_add_job_add_job = new javax.swing.JLabel();
		jLabel_jdialog_add_job_job_name = new javax.swing.JLabel();
		jLabel_jdialog_add_job_job_cost = new javax.swing.JLabel();
		jLabel_jdialog_add_job_job_state = new javax.swing.JLabel();
		jLabel_jdialog_add_job_job_due = new javax.swing.JLabel();
		jTextField_jdialog_job_add_job_name = new javax.swing.JTextField();
		jTextField_jdialog_job_add_job_cost = new javax.swing.JTextField();
		jTextField_jdialog_job_add_job_state = new javax.swing.JTextField();
		jTextField_jdialog_job_add_job_due = new javax.swing.JTextField();

		jButton_jdialog_add_job_add = new javax.swing.JButton();
		jTabbedPane_mainPane = new javax.swing.JTabbedPane();
		jPanel_Machines = new javax.swing.JPanel();
		jScrollPane_machines_table = new javax.swing.JScrollPane();
		jTable_machines = new javax.swing.JTable();
		jButton_remove_machine = new javax.swing.JButton();
		jButton_Add_Machine = new javax.swing.JButton();
		jPanel_Jobs = new javax.swing.JPanel();
		jScrollPane_jobs_table = new javax.swing.JScrollPane();
		jTable_jobs = new javax.swing.JTable();
		jButton_Add_Job = new javax.swing.JButton();
		jButton_remove_job = new javax.swing.JButton();
		jPanel_Schedulers = new javax.swing.JPanel();
		jLabel_schedularPane_Scheduler = new javax.swing.JLabel();
		jComboBox_schedulerPane_Scheduler = new javax.swing.JComboBox();
		jButton_schedulerPane_Schedule = new javax.swing.JButton();
		jSeparator_schedulerPane_top = new javax.swing.JSeparator();
		jScrollPane1 = new javax.swing.JScrollPane();
		jTextArea_schedulerPane_commandList = new javax.swing.JTextArea();
		jSeparator_schedulerPane_center = new javax.swing.JSeparator();
		menuBar = new javax.swing.JMenuBar();
		fileMenu = new javax.swing.JMenu();
		openMenuItem = new javax.swing.JMenuItem();
		saveMenuItem = new javax.swing.JMenuItem();
		saveAsMenuItem = new javax.swing.JMenuItem();
		exitMenuItem = new javax.swing.JMenuItem();
		editMenu = new javax.swing.JMenu();
		cutMenuItem = new javax.swing.JMenuItem();
		copyMenuItem = new javax.swing.JMenuItem();
		pasteMenuItem = new javax.swing.JMenuItem();
		deleteMenuItem = new javax.swing.JMenuItem();
		helpMenu = new javax.swing.JMenu();
		contentsMenuItem = new javax.swing.JMenuItem();
		aboutMenuItem = new javax.swing.JMenuItem();

		/**
		 * Machines dialog
		 */

		jDialog_Add_Machine.setMinimumSize(new java.awt.Dimension(300, 150));
		jDialog_Add_Machine.setModal(true);
		jDialog_Add_Machine.setResizable(false);

		jLabel_jdialog_add_machine_add_machine.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
		jLabel_jdialog_add_machine_add_machine.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		jLabel_jdialog_add_machine_add_machine.setText("Add Machine");

		jLabel_jdialog_add_machine_machine_name.setText("Machine Name");

		jButton_jdialog_add_machine_add.setText("Add");
		jButton_jdialog_add_machine_add.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton_jdialog_add_machine_addActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout jDialog_Add_MachineLayout = new javax.swing.GroupLayout(jDialog_Add_Machine.getContentPane());
		jDialog_Add_Machine.getContentPane().setLayout(jDialog_Add_MachineLayout);
		jDialog_Add_MachineLayout.setHorizontalGroup(jDialog_Add_MachineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				jDialog_Add_MachineLayout
						.createSequentialGroup()
						.addContainerGap()
						.addGroup(
								jDialog_Add_MachineLayout
										.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
										.addComponent(jLabel_jdialog_add_machine_add_machine, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
										.addGroup(
												jDialog_Add_MachineLayout.createSequentialGroup().addComponent(jLabel_jdialog_add_machine_machine_name).addGap(18, 18, 18)
														.addComponent(jTextField_jdialog_machine_add_machine_name, javax.swing.GroupLayout.DEFAULT_SIZE, 176, Short.MAX_VALUE))
										.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jDialog_Add_MachineLayout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(jButton_jdialog_add_machine_add))).addContainerGap()));
		jDialog_Add_MachineLayout.setVerticalGroup(jDialog_Add_MachineLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				jDialog_Add_MachineLayout
						.createSequentialGroup()
						.addContainerGap()
						.addComponent(jLabel_jdialog_add_machine_add_machine)
						.addGap(18, 18, 18)
						.addGroup(
								jDialog_Add_MachineLayout
										.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
										.addGroup(
												jDialog_Add_MachineLayout.createSequentialGroup()
														.addComponent(jTextField_jdialog_machine_add_machine_name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
														.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE).addComponent(jButton_jdialog_add_machine_add))
										.addGroup(jDialog_Add_MachineLayout.createSequentialGroup().addComponent(jLabel_jdialog_add_machine_machine_name).addGap(0, 0, Short.MAX_VALUE))).addContainerGap()));
		/**
		 * Jobs dialogs
		 */

		jDialog_Add_Job.setMinimumSize(new java.awt.Dimension(400, 360));
		jDialog_Add_Job.setResizable(false);

		jLabel_jdialog_add_job_add_job.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
		jLabel_jdialog_add_job_add_job.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		jLabel_jdialog_add_job_add_job.setText("Add Job");

		jLabel_jdialog_add_job_job_name.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		jLabel_jdialog_add_job_job_name.setText("Job Name");

		jLabel_jdialog_add_job_job_cost.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		jLabel_jdialog_add_job_job_cost.setText("Job Cost");

		// jLabel_jdialog_add_job_job_state.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		// jLabel_jdialog_add_job_job_state.setText("Job State");

		jLabel_jdialog_add_job_job_due.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		jLabel_jdialog_add_job_job_due.setText("Job Due");

		jTextField_jdialog_job_add_job_name.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jTextField_jdialog_job_add_job_nameActionPerformed(evt);
			}
		});

		jTextField_jdialog_job_add_job_cost.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jTextField_jdialog_job_add_job_costActionPerformed(evt);
			}
		});

		jButton_jdialog_add_job_add.setText("Add");
		jButton_jdialog_add_job_add.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton_jdialog_add_job_addActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout jDialog_Add_JobLayout = new javax.swing.GroupLayout(jDialog_Add_Job.getContentPane());
		jDialog_Add_Job.getContentPane().setLayout(jDialog_Add_JobLayout);
		jDialog_Add_JobLayout.setHorizontalGroup(jDialog_Add_JobLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				jDialog_Add_JobLayout
						.createSequentialGroup()
						.addGroup(
								jDialog_Add_JobLayout
										.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
										.addGroup(jDialog_Add_JobLayout.createSequentialGroup().addGap(25, 25, 25).addComponent(jLabel_jdialog_add_job_add_job, javax.swing.GroupLayout.PREFERRED_SIZE, 325, javax.swing.GroupLayout.PREFERRED_SIZE))
										.addGroup(
												jDialog_Add_JobLayout
														.createSequentialGroup()
														.addGap(18, 18, 18)
														.addGroup(
																jDialog_Add_JobLayout
																		.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
																		.addComponent(jButton_jdialog_add_job_add)
																		.addGroup(
																				jDialog_Add_JobLayout
																						.createSequentialGroup()
																						.addGroup(
																								jDialog_Add_JobLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
																										.addComponent(jLabel_jdialog_add_job_job_name, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
																										.addComponent(jLabel_jdialog_add_job_job_cost, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
																										.addComponent(jLabel_jdialog_add_job_job_due, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE))
																						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
																						.addGroup(
																								jDialog_Add_JobLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false).addComponent(jTextField_jdialog_job_add_job_cost)
																										.addComponent(jTextField_jdialog_job_add_job_name)
																										.addComponent(jTextField_jdialog_job_add_job_due, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE))))))
						.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
		jDialog_Add_JobLayout.setVerticalGroup(jDialog_Add_JobLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				jDialog_Add_JobLayout
						.createSequentialGroup()
						.addContainerGap()
						.addComponent(jLabel_jdialog_add_job_add_job, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
						.addGap(18, 18, 18)
						.addGroup(
								jDialog_Add_JobLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel_jdialog_add_job_job_name, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
										.addComponent(jTextField_jdialog_job_add_job_name, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
						.addGap(21, 21, 21)
						.addGroup(
								jDialog_Add_JobLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
										.addComponent(jLabel_jdialog_add_job_job_cost, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
										.addComponent(jTextField_jdialog_job_add_job_cost, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
						.addGap(18, 18, 18)
						.addGroup(
								jDialog_Add_JobLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
										.addComponent(jTextField_jdialog_job_add_job_due, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
										.addComponent(jLabel_jdialog_add_job_job_due, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
						.addComponent(jButton_jdialog_add_job_add).addGap(27, 27, 27)));

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		setMinimumSize(new java.awt.Dimension(415, 414));
		getContentPane().setLayout(new java.awt.CardLayout());

		jTable_machines.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {

		}, new String[] { "Name" }) {
			Class[] types = new Class[] { java.lang.String.class };

			@Override
			public Class getColumnClass(int columnIndex) {
				return types[columnIndex];
			}
		});
		jScrollPane_machines_table.setViewportView(jTable_machines);

		jButton_remove_machine.setText("-");
		jButton_remove_machine.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton_remove_machineActionPerformed(evt);
			}
		});

		jButton_Add_Machine.setText("+");
		jButton_Add_Machine.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton_Add_MachineActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout jPanel_MachinesLayout = new javax.swing.GroupLayout(jPanel_Machines);
		jPanel_MachinesLayout.setHorizontalGroup(jPanel_MachinesLayout.createParallelGroup(Alignment.LEADING).addGroup(
				jPanel_MachinesLayout
						.createSequentialGroup()
						.addGroup(
								jPanel_MachinesLayout.createParallelGroup(Alignment.LEADING)
										.addGroup(jPanel_MachinesLayout.createSequentialGroup().addContainerGap(295, Short.MAX_VALUE).addComponent(jButton_Add_Machine).addGap(18).addComponent(jButton_remove_machine))
										.addGroup(Alignment.TRAILING, jPanel_MachinesLayout.createSequentialGroup().addGap(136).addComponent(jScrollPane_machines_table, GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE))).addContainerGap()));
		jPanel_MachinesLayout.setVerticalGroup(jPanel_MachinesLayout.createParallelGroup(Alignment.LEADING).addGroup(
				Alignment.TRAILING,
				jPanel_MachinesLayout.createSequentialGroup().addComponent(jScrollPane_machines_table, GroupLayout.DEFAULT_SIZE, 276, Short.MAX_VALUE).addGap(17)
						.addGroup(jPanel_MachinesLayout.createParallelGroup(Alignment.BASELINE).addComponent(jButton_remove_machine).addComponent(jButton_Add_Machine)).addContainerGap()));
		jPanel_Machines.setLayout(jPanel_MachinesLayout);

		jTabbedPane_mainPane.addTab("Machines", jPanel_Machines);

		jTable_jobs.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {

		}, new String[] {
				"Name",
				"Cost",
				// "State",
				"Due" }) {
			Class[] types = new Class[] {
					java.lang.String.class,
					java.lang.Integer.class,
					// java.lang.Integer.class,
					java.lang.Integer.class };

			@Override
			public Class getColumnClass(int columnIndex) {
				return types[columnIndex];
			}
		});
		jTable_jobs.addKeyListener(new java.awt.event.KeyAdapter() {
			@Override
			public void keyReleased(java.awt.event.KeyEvent evt) {
				jTable_jobsKeyReleased(evt);
			}
		});
		jScrollPane_jobs_table.setViewportView(jTable_jobs);

		jButton_Add_Job.setText("+");
		jButton_Add_Job.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton_Add_JobActionPerformed(evt);
			}
		});

		jButton_remove_job.setText("-");
		jButton_remove_job.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton_remove_jobActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout jPanel_JobsLayout = new javax.swing.GroupLayout(jPanel_Jobs);
		jPanel_Jobs.setLayout(jPanel_JobsLayout);
		jPanel_JobsLayout.setHorizontalGroup(jPanel_JobsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				jPanel_JobsLayout
						.createSequentialGroup()
						.addContainerGap()
						.addGroup(
								jPanel_JobsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
										.addGroup(jPanel_JobsLayout.createSequentialGroup().addGap(0, 285, Short.MAX_VALUE).addComponent(jButton_Add_Job).addGap(18, 18, 18).addComponent(jButton_remove_job).addGap(10, 10, 10))
										.addGroup(jPanel_JobsLayout.createSequentialGroup().addComponent(jScrollPane_jobs_table, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE).addContainerGap()))));
		jPanel_JobsLayout.setVerticalGroup(jPanel_JobsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				jPanel_JobsLayout.createSequentialGroup().addContainerGap().addComponent(jScrollPane_jobs_table, javax.swing.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addGroup(jPanel_JobsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jButton_remove_job).addComponent(jButton_Add_Job)).addContainerGap()));

		jTabbedPane_mainPane.addTab("Jobs", jPanel_Jobs);

		jLabel_schedularPane_Scheduler.setText("Scheduler");

		jComboBox_schedulerPane_Scheduler.setModel(new DefaultComboBoxModel(new PriorityCalculator[] {
				new PriorityByCriticalRatio(),
				new PriorityByEarliestDueDate(),
				new PriorityByLongestImminentOperationTime(),
				new PriorityByShortestImminentOperationTime(),
				new PriorityBySmallestDynamicSlack(),
				new PriorityBySmallestStaticSlack() }));

		jComboBox_schedulerPane_Scheduler.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jComboBox_schedulerPane_SchedulerActionPerformed(evt);
			}
		});

		jButton_schedulerPane_Schedule.setText("Schedule");
		jButton_schedulerPane_Schedule.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton_schedulerPane_ScheduleActionPerformed(evt);
			}
		});

		jTextArea_schedulerPane_commandList.setEditable(false);
		jTextArea_schedulerPane_commandList.setColumns(20);
		jTextArea_schedulerPane_commandList.setRows(5);
		jScrollPane1.setViewportView(jTextArea_schedulerPane_commandList);

		javax.swing.GroupLayout jPanel_SchedulersLayout = new javax.swing.GroupLayout(jPanel_Schedulers);
		jPanel_Schedulers.setLayout(jPanel_SchedulersLayout);
		jPanel_SchedulersLayout.setHorizontalGroup(jPanel_SchedulersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				jPanel_SchedulersLayout
						.createSequentialGroup()
						.addContainerGap()
						.addGroup(
								jPanel_SchedulersLayout
										.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
										.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING)
										.addGroup(
												jPanel_SchedulersLayout.createSequentialGroup().addComponent(jLabel_schedularPane_Scheduler).addGap(18, 18, 18).addComponent(jComboBox_schedulerPane_Scheduler, 0, 235, Short.MAX_VALUE)
														.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jButton_schedulerPane_Schedule)).addComponent(jSeparator_schedulerPane_top)
										.addComponent(jSeparator_schedulerPane_center)).addContainerGap()));
		jPanel_SchedulersLayout.setVerticalGroup(jPanel_SchedulersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
				jPanel_SchedulersLayout
						.createSequentialGroup()
						.addContainerGap()
						.addGroup(
								jPanel_SchedulersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel_schedularPane_Scheduler)
										.addComponent(jComboBox_schedulerPane_Scheduler, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
										.addComponent(jButton_schedulerPane_Schedule)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addComponent(jSeparator_schedulerPane_top, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
						.addComponent(jSeparator_schedulerPane_center, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE).addContainerGap(128, Short.MAX_VALUE)));

		jTabbedPane_mainPane.addTab("Scheduler", jPanel_Schedulers);

		getContentPane().add(jTabbedPane_mainPane, "card2");

		jPanel_Grant = new JPanel();
		jTabbedPane_mainPane.addTab("Grant", null, jPanel_Grant, null);

		fileMenu.setMnemonic('f');
		fileMenu.setText("File");

		openMenuItem.setMnemonic('o');
		openMenuItem.setText("Open");
		fileMenu.add(openMenuItem);

		saveMenuItem.setMnemonic('s');
		saveMenuItem.setText("Save");
		fileMenu.add(saveMenuItem);

		saveAsMenuItem.setMnemonic('a');
		saveAsMenuItem.setText("Save As ...");
		saveAsMenuItem.setDisplayedMnemonicIndex(5);
		fileMenu.add(saveAsMenuItem);

		exitMenuItem.setMnemonic('x');
		exitMenuItem.setText("Exit");
		exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
			@Override
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				exitMenuItemActionPerformed(evt);
			}
		});
		fileMenu.add(exitMenuItem);

		menuBar.add(fileMenu);

		editMenu.setMnemonic('e');
		editMenu.setText("Edit");

		cutMenuItem.setMnemonic('t');
		cutMenuItem.setText("Cut");
		editMenu.add(cutMenuItem);

		copyMenuItem.setMnemonic('y');
		copyMenuItem.setText("Copy");
		editMenu.add(copyMenuItem);

		pasteMenuItem.setMnemonic('p');
		pasteMenuItem.setText("Paste");
		editMenu.add(pasteMenuItem);

		deleteMenuItem.setMnemonic('d');
		deleteMenuItem.setText("Delete");
		editMenu.add(deleteMenuItem);

		menuBar.add(editMenu);

		helpMenu.setMnemonic('h');
		helpMenu.setText("Help");

		contentsMenuItem.setMnemonic('c');
		contentsMenuItem.setText("Contents");
		helpMenu.add(contentsMenuItem);

		aboutMenuItem.setMnemonic('a');
		aboutMenuItem.setText("About");
		helpMenu.add(aboutMenuItem);

		menuBar.add(helpMenu);

		setJMenuBar(menuBar);

		pack();
	}// </editor-fold>//GEN-END:initComponents

	private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_exitMenuItemActionPerformed
		System.exit(0);
	}// GEN-LAST:event_exitMenuItemActionPerformed

	private void jButton_Add_MachineActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton_Add_MachineActionPerformed
		// TODO add your handling code here:
		// this.jDialog_Add_Machine.setModal(true);
		this.jTextField_jdialog_machine_add_machine_name.setText("");
		this.jDialog_Add_Machine.setVisible(true);
	}// GEN-LAST:event_jButton_Add_MachineActionPerformed

	private void jButton_jdialog_add_machine_addActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton_jdialog_add_machine_addActionPerformed
		// TODO add your handling code here:
		String machineName = this.jTextField_jdialog_machine_add_machine_name.getText();
		if ("".equals(machineName)) {
			return;
		}
		DefaultTableModel tbm = (DefaultTableModel) this.jTable_machines.getModel();

		tbm.addRow(new String[] { machineName });

		this.jTable_machines.setModel(tbm);
		this.jDialog_Add_Machine.setVisible(false);
	}// GEN-LAST:event_jButton_jdialog_add_machine_addActionPerformed

	private void jButton_remove_machineActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton_remove_machineActionPerformed
		// TODO add your handling code here:
		if (this.jTable_machines.getSelectedRow() == -1) {
			return;
		}
		DefaultTableModel dtm = (DefaultTableModel) this.jTable_machines.getModel();
		dtm.removeRow(this.jTable_machines.getSelectedRow());
		this.jTable_machines.setModel(dtm);

	}// GEN-LAST:event_jButton_remove_machineActionPerformed

	private void jButton_schedulerPane_ScheduleActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton_schedulerPane_ScheduleActionPerformed
		// TODO add your handling code here:
		// List<Machine> machines = new ArrayList<Machine>();
		// List<Job> jobs = new ArrayList<Job>();
		// SchedulerStrategy scheduler = (SchedulerStrategy)
		// this.jComboBox_schedulerPane_Scheduler.getSelectedItem();
		System.out.println(this.jComboBox_schedulerPane_Scheduler.getSelectedItem());
		for (int i = 0; i < this.jTable_machines.getRowCount(); i++) {
			// machines.add(new Machine(this.jTable_machines.getValueAt(i,
			// 0).toString()));
		}

		for (int i = 0; i < this.jTable_jobs.getRowCount(); i++) {
			// jobs.add(new Job(this.jTable_jobs.getValueAt(i, 0).toString(),
			// Integer.valueOf(this.jTable_jobs.getValueAt(i, 1).toString()),
			// Integer.valueOf(this.jTable_jobs.getValueAt(i, 2).toString()),
			// -1));
		}

		// this.ws = new WorkShop(machines, jobs, scheduler);
		this.jTextArea_schedulerPane_commandList.setText(this.ws.toString());// A
																				// schedulerPlan/t
																				// kene
																				// ide
																				// atadni
																				// sima
																				// String-kent
	}// GEN-LAST:event_jButton_schedulerPane_ScheduleActionPerformed

	private void jButton_Add_JobActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton_Add_JobActionPerformed
		// TODO add your handling code here:
		this.jTextField_jdialog_job_add_job_name.setText("");
		this.jDialog_Add_Job.setVisible(true);
	}// GEN-LAST:event_jButton_Add_JobActionPerformed

	private void jButton_remove_jobActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton_remove_jobActionPerformed
		// TODO add your handling code here:
		if (this.jTable_jobs.getSelectedRow() == -1) {
			return;
		}
		DefaultTableModel dtm = (DefaultTableModel) this.jTable_jobs.getModel();
		dtm.removeRow(this.jTable_jobs.getSelectedRow());
		this.jTable_jobs.setModel(dtm);
	}// GEN-LAST:event_jButton_remove_jobActionPerformed

	private void jTextField_jdialog_job_add_job_nameActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jTextField_jdialog_job_add_job_nameActionPerformed
		// TODO add your handling code here:
	}// GEN-LAST:event_jTextField_jdialog_job_add_job_nameActionPerformed

	private void jButton_jdialog_add_job_addActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton_jdialog_add_job_addActionPerformed
		// TODO add your handling code here:
		String jobName = this.jTextField_jdialog_job_add_job_name.getText();
		if ("".equals(jobName)) {
			return;
		}
		String jobCost = this.jTextField_jdialog_job_add_job_cost.getText();
		if ("".equals(jobCost)) {
			return;
		}
		// String jobState =
		// this.jTextField_jdialog_job_add_job_state.getText();
		// if ("".equals(jobState)) {
		// return;
		// }
		String jobDue = this.jTextField_jdialog_job_add_job_due.getText();
		if ("".equals(jobDue)) {
			return;
		}
		/*
		 * String jobDue = this.jTextField_jdialog_job_add_job_due.getText(); if
		 * ("".equals(jobDue)) { return; }
		 */

		if (jobCost.matches("[0-9]+") == false) {// RegEx regularis kifejezes
			return;
		}
		if (Integer.valueOf(jobCost) < 0) {
			return;
		}
		// if (Integer.valueOf(jobCost) < Integer.valueOf(jobState)) {
		// return;
		// }

		DefaultTableModel tbm = (DefaultTableModel) this.jTable_jobs.getModel();

		tbm.addRow(new String[] {
				jobName,
				jobCost,
				// jobState,
				jobDue });

		this.jTable_jobs.setModel(tbm);
		this.jDialog_Add_Job.setVisible(false);
	}// GEN-LAST:event_jButton_jdialog_add_job_addActionPerformed

	private void jTable_jobsKeyReleased(java.awt.event.KeyEvent evt) {// GEN-FIRST:event_jTable_jobsKeyReleased
		// TODO add your handling code here:
	}// GEN-LAST:event_jTable_jobsKeyReleased

	private void jTextField_jdialog_job_add_job_costActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jTextField_jdialog_job_add_job_costActionPerformed
		// TODO add your handling code here:
	}// GEN-LAST:event_jTextField_jdialog_job_add_job_costActionPerformed

	private void jComboBox_schedulerPane_SchedulerActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jComboBox_schedulerPane_SchedulerActionPerformed
		// TODO add your handling code here:
	}// GEN-LAST:event_jComboBox_schedulerPane_SchedulerActionPerformed

	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String args[]) {
		/*
		 * Set the Nimbus look and feel
		 */
		// <editor-fold defaultstate="collapsed"
		// desc=" Look and feel setting code (optional) ">
		/*
		 * If Nimbus (introduced in Java SE 6) is not available, stay with the
		 * default look and feel. For details see
		 * http://download.oracle.com/javase
		 * /tutorial/uiswing/lookandfeel/plaf.html
		 */
		try {
			for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
				if ("Nimbus".equals(info.getName())) {
					javax.swing.UIManager.setLookAndFeel(info.getClassName());
					break;
				}
			}
		} catch (ClassNotFoundException ex) {
			java.util.logging.Logger.getLogger(AppWindow2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
		} catch (InstantiationException ex) {
			java.util.logging.Logger.getLogger(AppWindow2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
		} catch (IllegalAccessException ex) {
			java.util.logging.Logger.getLogger(AppWindow2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
		} catch (javax.swing.UnsupportedLookAndFeelException ex) {
			java.util.logging.Logger.getLogger(AppWindow2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
		}
		// </editor-fold>

		/*
		 * Create and display the form
		 */
		java.awt.EventQueue.invokeLater(new Runnable() {

			@Override
			public void run() {
				new AppWindow2().setVisible(true);
			}
		});
	}

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JMenuItem aboutMenuItem;
	private javax.swing.JMenuItem contentsMenuItem;
	private javax.swing.JMenuItem copyMenuItem;
	private javax.swing.JMenuItem cutMenuItem;
	private javax.swing.JMenuItem deleteMenuItem;
	private javax.swing.JMenu editMenu;
	private javax.swing.JMenuItem exitMenuItem;
	private javax.swing.JMenu fileMenu;
	private javax.swing.JMenu helpMenu;
	private javax.swing.JButton jButton_Add_Job;
	private javax.swing.JButton jButton_Add_Machine;
	private javax.swing.JButton jButton_jdialog_add_job_add;
	private javax.swing.JButton jButton_jdialog_add_machine_add;
	private javax.swing.JButton jButton_remove_job;
	private javax.swing.JButton jButton_remove_machine;
	private javax.swing.JButton jButton_schedulerPane_Schedule;
	private javax.swing.JComboBox jComboBox_schedulerPane_Scheduler;
	private javax.swing.JDialog jDialog_Add_Job;
	private javax.swing.JDialog jDialog_Add_Machine;
	private javax.swing.JLabel jLabel_jdialog_add_job_add_job;
	private javax.swing.JLabel jLabel_jdialog_add_job_job_cost;
	private javax.swing.JLabel jLabel_jdialog_add_job_job_name;
	private javax.swing.JLabel jLabel_jdialog_add_job_job_state;
	private javax.swing.JLabel jLabel_jdialog_add_job_job_due;
	private javax.swing.JLabel jLabel_jdialog_add_machine_add_machine;
	private javax.swing.JLabel jLabel_jdialog_add_machine_machine_name;
	private javax.swing.JLabel jLabel_schedularPane_Scheduler;
	private javax.swing.JPanel jPanel_Jobs;
	private javax.swing.JPanel jPanel_Machines;
	private javax.swing.JPanel jPanel_Schedulers;
	private javax.swing.JScrollPane jScrollPane1;
	private javax.swing.JScrollPane jScrollPane_jobs_table;
	private javax.swing.JScrollPane jScrollPane_machines_table;
	private javax.swing.JSeparator jSeparator_schedulerPane_center;
	private javax.swing.JSeparator jSeparator_schedulerPane_top;
	private javax.swing.JTabbedPane jTabbedPane_mainPane;
	private javax.swing.JTable jTable_jobs;
	private javax.swing.JTable jTable_machines;
	private javax.swing.JTextArea jTextArea_schedulerPane_commandList;
	private javax.swing.JTextField jTextField_jdialog_job_add_job_cost;
	private javax.swing.JTextField jTextField_jdialog_job_add_job_name;
	private javax.swing.JTextField jTextField_jdialog_job_add_job_state;
	private javax.swing.JTextField jTextField_jdialog_job_add_job_due;
	private javax.swing.JTextField jTextField_jdialog_machine_add_machine_name;
	private javax.swing.JMenuBar menuBar;
	private javax.swing.JMenuItem openMenuItem;
	private javax.swing.JMenuItem pasteMenuItem;
	private javax.swing.JMenuItem saveAsMenuItem;
	private javax.swing.JMenuItem saveMenuItem;
	private JPanel jPanel_Grant;
}
